#include <algorithm>
#include <string.h>
#include <iostream>
#include "HRDepartment.h"

CHRDepartment::CHRDepartment( const char* szName )
{
	m_lstDepartments.clear();
	memset( m_szName, 0, 255 );

	strcpy_s( m_szName, strlen(szName) + 1, szName );
}

CHRDepartment::~CHRDepartment()
{

}

bool CHRDepartment::Add( IRootDepartment* department )
{
	if ( 0 == department )
		return false;

	m_lstDepartments.push_back( department );
	return true;
}

bool CHRDepartment::Remove( IRootDepartment* department )
{
	if ( 0 == department )
		return false;

	m_lstDepartments.erase( std::find( m_lstDepartments.begin(), m_lstDepartments.end(), department ) );
	return true;
}

bool CHRDepartment::Display()
{
	std::cout << "---" << m_szName << std::endl;

	for ( std::list<IRootDepartment*>::const_iterator iter = m_lstDepartments.begin();
		iter != m_lstDepartments.end(); ++iter )
	{
		(*iter)->Display();
	}

	return true;
}
